# from unittest import TestCase
#
#
# # Create your tests here.
# import requests
#
#
# class StockTest(TestCase):
#     base_url = 'http://127.0.0.1:8000'
#
#     def Test_wareHouse(self):
#         url = self.base_url + '/stock/warehouse/'
#         resp = requests.get(url)
#         print(resp.text)


from unittest import TestCase
import requests


# Create your tests here.


class DealerTest(TestCase):
    base_url = 'http://127.0.0.1:8000'

    def test_wareHouse(self):
        """
            查询所有仓库信息
        :return:
        """
        url = self.base_url + '/stock/warehouse/'
        resp = requests.get(url)
        print(resp.text)

    def test_goods(self):
        """
            查看所有商品
        :return:
        """
        url = self.base_url + '/stock/goods/'
        resp = requests.get(url)
        print(resp.text)

    def test_stock(self):
        """
            查看所有库存
        :return:
        """
        url = self.base_url + '/stock/stock/'
        resp = requests.get(url)
        print(resp.text)

    def test_changeStock(self):
        """
            查看所有库存
        :return:
        """
        url = self.base_url + '/stock/change_stock/'
        json_data = {
            "stock_id":"19a759409dc2478a81ebd2ebd355d127",
            "num" :-200,
        }
        resp = requests.post(url,data=json_data)
        print(resp.text)

    def test_checkStock(self):
        """
            按照城市搜索仓库
            改进，姓名，和其他条件查询（可以合并）
        :return:
        """
        url = self.base_url + '/stock/check_stock/?para=西安'
        resp = requests.get(url)
        print(resp.text)

    def test_add_ware(self):
        url = self.base_url + '/stock/add_ware/'
        json_data = {
            'name':'陕西省渭南市临渭区酒韵仓',
            'city':'渭南',
            'address':'陕西省渭南市临渭区东兴街11号',
            'latitude':'33.678',
            'longitude':'99.87',
            'area':'渭南市渭北5县',
            'staff_name':'张三',
            'overview':'高层仓一座，楼高6层:每层三个区:每层高为4.95米:另外建有两座平面仓，总面积为5万平方米;仓库内承重3.3吨酒，电动升降装卸平台30部，叉车35部，可供全天候作业，配有自动报警、喷淋消防及抽风机调温系统和清扫吸尘机械，确保货物安全和存储质量。',
        }
        resp = requests.post(url,data=json_data)
        print(resp.text)

    def test_add_goods(self):
        url = self.base_url + '/stock/add_goods/'
        json_data = {
            'name':'50年国花瓷西凤酒45度',
            'kind':'国花瓷',
            'cost':6144,
            'retail':6792,
            'img':'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fm.360buyimg.com%2Fmobilecms%2Fs750x750_jfs%2Ft19084%2F277%2F1122532717%2F214360%2F2d37140d%2F5abdf132Nf906a65e.jpg%21q80.jpg&refer=http%3A%2F%2Fm.360buyimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1628404299&t=a4de1698b331216c226f08f92f964bed',
        }
        resp = requests.post(url,data=json_data)
        print(resp.text)


    def test_add_stock(self):
        url = self.base_url + '/stock/add_stock/'
        json_data = {
            'goods_id':'1',
            'ware_id':'06cf045036044359a1608d846caab282',
            'num':'S000000002',
            'city':'西安',
            'kind': '国花瓷',
            'count':2000,
            'detail':'华山论剑',
            'location':'B-02-C3-L1',
        }
        resp = requests.post(url,data=json_data)
        print(resp.text)